<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|应用被启动并且所有的服务提供者被注册，Request将会被传到路由器进行分发，
|路由器将请求分发到路由或控制器，同时运行所有路由指定的中间件
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

/**
 *
 */
Route::group(['namespace'=>'Test'],function(){

    Route::get('index','TestController@index');
    Route::get('create','TestController@create');
    Route::get('update','TestController@update');
    Route::get('delete','TestController@delete');

    Route::get('socket','TestController@socket');

    Route::get('bridge',function(){
       //$pusher=\Illuminate\Support\Facades\App::make('pusher'); //$app_secret, $app_id,'cluster' => $app_cluster,

        $app_key=getenv('PUSHER_KEY');
        $app_secret=getenv('PUSHER_SECRET');
        $app_id=getenv('PUSHER_APP_ID');
        $app_cluster=getenv('PUSHER_APP_CLUSTER');


        $pusher = new Pusher\Pusher( $app_key, $app_secret, $app_id, array( 'cluster' => $app_cluster) );



       $res=$pusher->trigger('test-channel',
                        'test-event',
                        ['text'=>'i am rich chigga']
           );
//        dd($res);



       return 'This is a Laravel Pusher Bridge Test!';
    });


    Route::get('broadcast', function () {
        event(new \App\Events\PusherEvent('i got my slash', '1'));

        return 'This is a Laravel Broadcaster Test!';
    });




    Route::get('relate','TestController@relate');
    //队列
    Route::get('queue','MessageController@index');

    //实时消息
    Route::get('notifications','NotificationController@getIndex');
    Route::post('notify','NotificationController@postNotify');

    //点赞及状态发布
    Route::get('activity','ActivityController@getIndex');
    Route::post('activities/like/{id}','ActivityController@postLike');
    Route::post('activities/status-update','ActivityController@postStatusUpdate');
    //聊天
    Route::get('chat','ChatController@getIndex');
    Route::post('chat/message','ChatController@postMessage');

    Route::get('spaider','TestController@spaider');

    Route::get('carhome','TestController@carhome');

    Route::resource('post','PostController');
});




Route::get('auth/github/callback','Auth\AuthController@handleProviderCallback');

